package com.cjack.frenchexcel.dao;

import com.cjack.frenchexcel.table.QontoTable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

/**
 * qonto流水管理
 * Created by root on 10/5/19
 */
public interface QontoDao extends JpaRepository<QontoTable, Long>, JpaSpecificationExecutor<QontoTable> {

    QontoTable findByTransactionId( String transactionId);

    @Query( value = " select  sum(amount) amount from fe_qonto where side = ?1", nativeQuery = true)
    Double sumBySide( String side);

    @Query( value = " select * from fe_qonto where id!=?1 and invoice is not null and (invoice_status is null or invoice_status != 'PASS') order by id asc limit 1", nativeQuery = true)
    QontoTable getLastById( Long id);

    QontoTable getByUniqueSign( String uniqueSign);

}
